package IO;



import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

public class level {
	// private int levelWidth, levelHeight; 
	//private ArrayList<Path> paths;
	// private String levelName;
	// private int goalX, goalY;
	// private int numOfSpawns;
	// private int[] spawnLoc;
	

	private char[][] fullLevel;
	private ArrayList<Path> levelPaths;
	
	public level(File levelLoc) throws IOException
	{
		String unconverted, levelLocation;
		levelLocation = levelLoc.getPath();
		unconverted = parser.levelReader(levelLocation);
		this.fullLevel = parser.levelConverter(unconverted, this);
		
		for(int i = 0; i < this.levelPaths.size(); i++)
		{
			System.out.println("Paths for Creeps:");
			for(int j = 0; j < this.levelPaths.get(i).getMaxWayPoint(); j++)
			{
			System.out.println(levelPaths.get(i).getWayPoint(j).getX() +"/"+ levelPaths.get(i).getWayPoint(j).getY());
			}
		}
	}
	
	public level(String unconverted)
	{
		this.fullLevel = parser.levelConverter(unconverted, this);
	}
	
	public level(char[][] level)
	{
		this.fullLevel = level;
	}
	
	// @deprecated
	public void loadLevel(String levelLoc) throws IOException
	{
		this.fullLevel = parser.levelConverter(parser.levelReader(levelLoc), this);
	}
	
	public void saveLevel(String location) throws IOException
	{
		parser.toStringAndSave(this.fullLevel, location);
	}
	
	public String convertLevel()
	{
		return parser.toString(this.fullLevel);
	}
	
	public void setPaths(ArrayList<Path> path)
	{
		this.levelPaths = path;
	}
	
	public ArrayList<Path> getPaths()
	{
		return levelPaths;
	}
	
	public char[][] returnLevel()
	{
		return fullLevel;
	}
	

}
